//
//  NSString+JSON.m
//  CTalk
//
//  Created by Gao Yongqing on 8/28/15.
//  Copyright (c) 2015 Chinac.com. All rights reserved.
//

#import "NSString+JSON.h"

@implementation NSString (JSON)

- (id)toJson
{
    NSError *jsonError;
    NSData *objectData = [self dataUsingEncoding:NSUTF8StringEncoding];
    NSDictionary *jsonContent = [NSJSONSerialization JSONObjectWithData:objectData
                                                                options:NSJSONReadingMutableContainers
                                                                  error:&jsonError];
    
    if (jsonError) {
        NSLog(@"Parse Json from string: %@ ERROR: %@", self, jsonError);
    }
    
    return jsonContent;
}

@end
